package org.compression.controller;

import java.io.IOException;
import java.util.List;

import org.apache.log4j.Logger;
import org.compression.services.imp.SearchServiceImp;
import org.model.Condition;
import org.model.HigSearch;
import org.model.MagazineAttrs;
import org.model.TNewMagazine;
import org.model.business.BookAttrReturn;
import org.model.comm.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class SearchController {

	private static Logger logger = Logger.getLogger(SearchController.class);

	@Autowired
	SearchServiceImp mSearchServiceImp;

	@RequestMapping(value ="/getCategory", method = RequestMethod.GET)
	public Object getCategory() throws IOException {
		return mSearchServiceImp.getCategory();
	}


	@RequestMapping(value ="/getMagazine", method = RequestMethod.GET)
	public Object getMagazine() throws IOException {
		return mSearchServiceImp.getMagazine();
	}

	//查询杂志根据类型id
	@RequestMapping(value ="/getCategoryId/{id}", method = RequestMethod.GET)
	public Object getCategoryId(@PathVariable String id) throws IOException {
		return mSearchServiceImp.getCategoryId(id);
	}

	//查询杂志根据id
	@RequestMapping(value ="/getMaginzeId/{id}", method = RequestMethod.GET)
	public Object getMaginzeId(@PathVariable String id) throws IOException {
		return mSearchServiceImp.getMaginzeId(id);
	}


	//查询书名
	@RequestMapping(value ="/getMaginzeName", method = RequestMethod.POST)
	public Object getMaginzeName(@RequestBody String name) {
		return mSearchServiceImp.getMaginzeName(name);
	}

	//插入书本
	@RequestMapping(value ="/insertMaginze/", method = RequestMethod.POST)
	public void getMaginzeId(@RequestBody TNewMagazine model) throws IOException {
		mSearchServiceImp.insertMaginze(model);
	}

	//插入书本属性
	@RequestMapping(value ="/insertMagazineattrs/", method = RequestMethod.POST)
	public void insertMagazineattrs(@RequestBody MagazineAttrs model) throws IOException {
		mSearchServiceImp.insertMagazineattrs(model);
	}

	//搜索书籍标题
	@RequestMapping(value ="/searchbooktitle/", method = RequestMethod.POST)
	public Object searchbooktitle(@RequestBody MagazineAttrs model) throws IOException {
		
		return null;
	}
	//高级查询
	@RequestMapping(value ="/getHigSearch/", method = RequestMethod.POST)
	public Object getHigSearch(@RequestBody HigSearch mHigSearch) {
		return mSearchServiceImp.getHigSearch(mHigSearch.getId(),mHigSearch.getValues());
	}
	//高级查询 或非于
	@RequestMapping(value ="/getHighSelect/", method = RequestMethod.POST)
	public Object getHighSelect(@RequestBody Condition mCondition) throws Exception {
	//	logger.info(mHigSearch);
		return  mSearchServiceImp.getHighSelect(mCondition);
	}
	
	//查询条件值
	@RequestMapping(value ="/selectIdContional/", method = RequestMethod.GET)
	public Object selectIdContional() throws Exception {
		return mSearchServiceImp.selectIdContional();
	}
	
	@RequestMapping(value ="/getDesc/", method = RequestMethod.GET)
	public Object getDesc() {
		return mSearchServiceImp.getDesc();
	}
	
	@RequestMapping(value ="/getAllBook/", method = RequestMethod.GET)
	public Object getAllBook(){
		return mSearchServiceImp.getAllBook();
	}
	
	
	
	@RequestMapping(value ="/page", method = RequestMethod.POST)
	public Object getPageMember(@RequestBody Page mPage){
		return null;
	}
	
	
	@RequestMapping(value ="/selectByIdListMagazineIds/{id}", method = RequestMethod.POST)
	public Object selectByIdListMagazineIds(@RequestBody BookAttrReturn mBookAttrReturn) {
		return mSearchServiceImp.selectByIdListMagazineIds(mBookAttrReturn);
	}
	
	
	
	
	
	
}
